package me.macd.mindoc.service.impl;

import me.macd.mindoc.dao.LabelDao;
import me.macd.mindoc.model.Label;
import me.macd.mindoc.service.LabelService;
import me.macd.mindoc.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @program: mindoc
 * @description: ${description}
 * @author: 2018-09-22
 * @create: 2018-09-22 22:00
 */
@Service
public class LabelServiceImpl implements LabelService {

    @Autowired
    LabelDao labelDao;

    @Override
    @Transactional(propagation = Propagation.SUPPORTS)
    public Page<Label> findToPager(int pageIndex, int pageSize) {
        Page<Label> page = new Page<>();
        int offset = (pageIndex - 1) * pageSize;
        page.setTotalCount(labelDao.countToPager());
        page.setItems(labelDao.findToPager(offset, pageSize));
        return page;
    }
}
